
//
//  NSString+LHLBase64.m
//  UI_24_加密
//
//  Created by 李昊林 on 16/8/16.
//  Copyright © 2016年 li cheng. All rights reserved.
//

#import "NSString+LHLBase64.h"

@implementation NSString (LHLBase64)
- (NSString *)stringWithBase64{
    //NSString转NSData
    NSData *stringData = [self dataUsingEncoding:NSUTF8StringEncoding];
    //NSData进行Base64，生成字符串
    NSString *Base64String = [stringData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    return Base64String;
}
- (NSData *)base64StringWithData {
    return [[NSData alloc] initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
}

- (NSString *)base64WithString{
    //根据Base64字符串，生成NSData
    NSData *base64Data = [[NSData alloc]initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
    //把NSData 转成字符串
    NSString *orginString = [[NSString alloc] initWithData:base64Data encoding:NSUTF8StringEncoding];
    return orginString;
}
@end
